module derelict.newton.funcs;

import derelict.newton.types;

extern(C):

// World control functions
typedef NewtonWorld* function(NewtonAllocMemory malloc, NewtonFreeMemory mfree) pfNewtonCreate;
typedef void function(const NewtonWorld* newtonWorld) pfNewtonDestroy;
typedef void function(const NewtonWorld* newtonWorld) pfNewtonDestroyAllBodies;
typedef void function(const NewtonWorld* newtonWorld, dFloat timestep) pfNewtonUpdate;
typedef void function(const NewtonWorld* newtonWorld, int model) pfNewtonSetSolverModel;
typedef void function(const NewtonWorld* newtonWorld, int model) pfNewtonSetFrictionModel;
typedef dFloat function(const NewtonWorld* newtonWorld) pfNewtonGetTimeStep;
typedef void function(const NewtonWorld* newtonWorld, dFloat frameRate) pfNewtonSetMinimumFrameRate;
typedef void function(const NewtonWorld* newtonWorld, NewtonBodyLeaveWorld callback) pfNewtonSetBodyLeaveWorldEvent;
typedef void function(const NewtonWorld* newtonWorld, const dFloat* minPoint, const dFloat* maxPoint) pfNewtonSetWorldSize;
typedef void function(const NewtonWorld* newtonWorld, const NewtonBody* body_) pfNewtonWorldFreezeBody;
typedef void function(const NewtonWorld* newtonWorld, const NewtonBody* body_) pfNewtonWorldUnfreezeBody;
typedef void function(const NewtonWorld* newtonWorld, NewtonBodyIterator callback) pfNewtonWorldForEachBodyDo;
typedef void function(const NewtonWorld* newtonWorld, void* userData) pfNewtonWorldSetUserData;
typedef void* function(const NewtonWorld* newtonWorld) pfNewtonWorldGetUserData;
typedef int function(const NewtonWorld* newtonWorld) pfNewtonWorldGetVersion;
typedef void function(const NewtonWorld* newtonWorld, const dFloat* p0, const dFloat* p1, NewtonWorldRayFilterCallback filter, void* userData) pfNewtonWorldRayCast;
typedef int function(const NewtonWorld* newtonWorld, int maxSize, const NewtonCollision* collsionA, const dFloat* matrixA, const NewtonCollision* collsionB, const dFloat* matrixB, dFloat* contacts, dFloat* normals, dFloat* penetration) pfNewtonWorldCollide;

pfNewtonCreate NewtonCreate;
pfNewtonDestroy NewtonDestroy;
pfNewtonDestroyAllBodies NewtonDestroyAllBodies;
pfNewtonUpdate NewtonUpdate;
pfNewtonSetSolverModel NewtonSetSolverModel;
pfNewtonSetFrictionModel NewtonSetFrictionModel;
pfNewtonGetTimeStep NewtonGetTimeStep;
pfNewtonSetMinimumFrameRate NewtonSetMinimumFrameRate;
pfNewtonSetBodyLeaveWorldEvent NewtonSetBodyLeaveWorldEvent;
pfNewtonSetWorldSize NewtonSetWorldSize;
pfNewtonWorldFreezeBody NewtonWorldFreezeBody;
pfNewtonWorldUnfreezeBody NewtonWorldUnfreezeBody;
pfNewtonWorldForEachBodyDo NewtonWorldForEachBodyDo;
pfNewtonWorldSetUserData NewtonWorldSetUserData;
pfNewtonWorldGetUserData NewtonWorldGetUserData;
pfNewtonWorldGetVersion NewtonWorldGetVersion;
pfNewtonWorldRayCast NewtonWorldRayCast;
pfNewtonWorldCollide NewtonWorldCollide;


// Physics Material Section
typedef int function(const NewtonWorld* newtonWorld) pfNewtonMaterialGetDefaultGroupID;
typedef int function(const NewtonWorld* newtonWorld) pfNewtonMaterialCreateGroupID;
typedef void function(const NewtonWorld* newtonWorld) pfNewtonMaterialDestroyAllGroupID;
typedef void function(const NewtonWorld* newtonWorld, int id0, int id1, dFloat value) pfNewtonMaterialSetDefaultSoftness;
typedef void function(const NewtonWorld* newtonWorld, int id0, int id1, dFloat elasticCoef) pfNewtonMaterialSetDefaultElasticity;
typedef void function(const NewtonWorld* newtonWorld, int id0, int id1, int state) pfNewtonMaterialSetDefaultCollidable;
typedef void function(const NewtonWorld* newtonWorld, int id0, int id1, dFloat staticFriction, dFloat kineticFriction) pfNewtonMaterialSetDefaultFriction;
typedef void function(const NewtonWorld* newtonWorld, int id0, int id1, void* userData, NewtonContactBegin begin, NewtonContactProcess process, NewtonContactEnd end) pfNewtonMaterialSetCollisionCallback;
typedef void* function(const NewtonWorld* newtonWorld, int id0, int id1) pfNewtonMaterialGetUserData;

pfNewtonMaterialGetDefaultGroupID NewtonMaterialGetDefaultGroupID;
pfNewtonMaterialCreateGroupID NewtonMaterialCreateGroupID;
pfNewtonMaterialDestroyAllGroupID NewtonMaterialDestroyAllGroupID;
pfNewtonMaterialSetDefaultSoftness NewtonMaterialSetDefaultSoftness;
pfNewtonMaterialSetDefaultElasticity NewtonMaterialSetDefaultElasticity;
pfNewtonMaterialSetDefaultCollidable NewtonMaterialSetDefaultCollidable;
pfNewtonMaterialSetDefaultFriction NewtonMaterialSetDefaultFriction;
pfNewtonMaterialSetCollisionCallback NewtonMaterialSetCollisionCallback;
pfNewtonMaterialGetUserData NewtonMaterialGetUserData;


// Physics Contact control functions
typedef void function(const NewtonMaterial* material) pfNewtonMaterialDisableContact;
typedef dFloat function(const NewtonMaterial* material) pfNewtonMaterialGetCurrentTimestep;
typedef void* function(const NewtonMaterial* material) pfNewtonMaterialGetMaterialPairUserData;
typedef uint function(const NewtonMaterial* material) pfNewtonMaterialGetContactFaceAttribute;
typedef uint function(const NewtonMaterial* material, const NewtonBody* body_) pfNewtonMaterialGetBodyCollisionID;
typedef dFloat function(const NewtonMaterial* material, const NewtonContact* contactlHandle) pfNewtonMaterialGetContactNormalSpeed;
typedef void function(const NewtonMaterial* material, dFloat* force) pfNewtonMaterialGetContactForce;
typedef void function(const NewtonMaterial* material, dFloat* posit, dFloat* normal) pfNewtonMaterialGetContactPositionAndNormal;
typedef void function(const NewtonMaterial* material, dFloat* dir0, dFloat* dir) pfNewtonMaterialGetContactTangentDirections;
typedef dFloat function(const NewtonMaterial* material, const NewtonContact* contactlHandle, int index) pfNewtonMaterialGetContactTangentSpeed;
typedef void function(const NewtonMaterial* material, dFloat softness) pfNewtonMaterialSetContactSoftness;
typedef void function(const NewtonMaterial* material, dFloat restitution) pfNewtonMaterialSetContactElasticity;
typedef void function(const NewtonMaterial* material, int state, int index) pfNewtonMaterialSetContactFrictionState;
typedef void function(const NewtonMaterial* material, dFloat coef, int index) pfNewtonMaterialSetContactStaticFrictionCoef;
typedef void function(const NewtonMaterial* material, dFloat coef, int index) pfNewtonMaterialSetContactKineticFrictionCoef;
typedef void function(const NewtonMaterial* material, dFloat accel, int index) pfNewtonMaterialSetContactTangentAcceleration;
typedef void function(const NewtonMaterial* material, const dFloat* directionVector) pfNewtonMaterialContactRotateTangentDirections;

pfNewtonMaterialDisableContact NewtonMaterialDisableContact;
pfNewtonMaterialGetCurrentTimestep NewtonMaterialGetCurrentTimestep;
pfNewtonMaterialGetMaterialPairUserData NewtonMaterialGetMaterialPairUserData;
pfNewtonMaterialGetContactFaceAttribute NewtonMaterialGetContactFaceAttribute;
pfNewtonMaterialGetBodyCollisionID NewtonMaterialGetBodyCollisionID;
pfNewtonMaterialGetContactNormalSpeed NewtonMaterialGetContactNormalSpeed;
pfNewtonMaterialGetContactForce NewtonMaterialGetContactForce;
pfNewtonMaterialGetContactPositionAndNormal NewtonMaterialGetContactPositionAndNormal;
pfNewtonMaterialGetContactTangentDirections NewtonMaterialGetContactTangentDirections;
pfNewtonMaterialGetContactTangentSpeed NewtonMaterialGetContactTangentSpeed;
pfNewtonMaterialSetContactSoftness NewtonMaterialSetContactSoftness;
pfNewtonMaterialSetContactElasticity NewtonMaterialSetContactElasticity;
pfNewtonMaterialSetContactFrictionState NewtonMaterialSetContactFrictionState;
pfNewtonMaterialSetContactStaticFrictionCoef NewtonMaterialSetContactStaticFrictionCoef;
pfNewtonMaterialSetContactKineticFrictionCoef NewtonMaterialSetContactKineticFrictionCoef;
pfNewtonMaterialSetContactTangentAcceleration NewtonMaterialSetContactTangentAcceleration;
pfNewtonMaterialContactRotateTangentDirections NewtonMaterialContactRotateTangentDirections;


// Convex collision primitives creation functions
typedef NewtonCollision* function(const NewtonWorld* newtonWorld) pfNewtonCreateNull;
typedef NewtonCollision* function(const NewtonWorld* newtonWorld, dFloat radiusX, dFloat radiusY, dFloat radiusZ, const dFloat *offsetMatrix) pfNewtonCreateSphere;
typedef NewtonCollision* function(const NewtonWorld* newtonWorld, dFloat dx, dFloat dy, dFloat dz, const dFloat *offsetMatrix) pfNewtonCreateBox;
typedef NewtonCollision* function(const NewtonWorld* newtonWorld, dFloat radius, dFloat height, const dFloat *offsetMatrix) pfNewtonCreateCone;
typedef NewtonCollision* function(const NewtonWorld* newtonWorld, dFloat radius, dFloat height, const dFloat *offsetMatrix) pfNewtonCreateCapsule;
typedef NewtonCollision* function(const NewtonWorld* newtonWorld, dFloat radius, dFloat height, const dFloat *offsetMatrix) pfNewtonCreateCylinder;
typedef NewtonCollision* function(const NewtonWorld* newtonWorld, dFloat radius, dFloat height, const dFloat *offsetMatrix) pfNewtonCreateChamferCylinder;
typedef NewtonCollision* function(const NewtonWorld* newtonWorld, int count, dFloat* vertexCloud, int strideInBytes, dFloat *offsetMatrix) pfNewtonCreateConvexHull;
typedef NewtonCollision* function(const NewtonWorld* newtonWorld, const NewtonCollision* convexHullCollision) pfNewtonCreateConvexHullModifier;
typedef void function(const NewtonCollision* convexHullCollision, dFloat* matrix) pfNewtonConvexHullModifierGetMatrix;
typedef void function(const NewtonCollision* convexHullCollision, const dFloat* matrix) pfNewtonConvexHullModifierSetMatrix;
typedef void function(const NewtonCollision* convexCollision, uint id) pfNewtonConvexCollisionSetUserID;
typedef uint  function(const NewtonCollision* convexCollision) pfNewtonConvexCollisionGetUserID;

pfNewtonCreateNull NewtonCreateNull;
pfNewtonCreateSphere NewtonCreateSphere;
pfNewtonCreateBox NewtonCreateBox;
pfNewtonCreateCone NewtonCreateCone;
pfNewtonCreateCapsule NewtonCreateCapsule;
pfNewtonCreateCylinder NewtonCreateCylinder;
pfNewtonCreateChamferCylinder NewtonCreateChamferCylinder;
pfNewtonCreateConvexHull NewtonCreateConvexHull;
pfNewtonCreateConvexHullModifier NewtonCreateConvexHullModifier;
pfNewtonConvexHullModifierGetMatrix NewtonConvexHullModifierGetMatrix;
pfNewtonConvexHullModifierSetMatrix NewtonConvexHullModifierSetMatrix;
pfNewtonConvexCollisionSetUserID NewtonConvexCollisionSetUserID;
pfNewtonConvexCollisionGetUserID NewtonConvexCollisionGetUserID;


// Complex collision primitives creation functions
// Note: can only be used with static bodies (bodies with infinite mass)
typedef NewtonCollision* function(const NewtonWorld* newtonWorld, int count, NewtonCollision* collisionPrimitiveArray[]) pfNewtonCreateCompoundCollision;
typedef NewtonCollision* function(const NewtonWorld* newtonWorld, const dFloat *minBox, const dFloat *maxBox, void *userData, NewtonUserMeshCollisionCollideCallback collideCallback, NewtonUserMeshCollisionRayHitCallback rayHitCallback, NewtonUserMeshCollisionDestroyCallback destroyCallback) pfNewtonCreateUserMeshCollision;

pfNewtonCreateCompoundCollision NewtonCreateCompoundCollision;
pfNewtonCreateUserMeshCollision NewtonCreateUserMeshCollision;


// CollisionTree Utility functions
typedef NewtonCollision* function(const NewtonWorld* newtonWorld, NewtonTreeCollisionCallback userCallback) pfNewtonCreateTreeCollision;
typedef void function(const NewtonCollision* treeCollision) pfNewtonTreeCollisionBeginBuild;
typedef void function(const NewtonCollision* treeCollision, int vertexCount, const dFloat* vertexPtr, int strideInBytes, int faceAttribute) pfNewtonTreeCollisionAddFace;
typedef void function(const NewtonCollision* treeCollision, int optimize) pfNewtonTreeCollisionEndBuild;
typedef void function(const NewtonCollision* treeCollision, NewtonSerialize serializeFunction, void* serializeHandle) pfNewtonTreeCollisionSerialize;
typedef NewtonCollision* function(const NewtonWorld* newtonWorld, NewtonTreeCollisionCallback userCallback, NewtonDeserialize deserializeFunction, void* serializeHandle) pfNewtonCreateTreeCollisionFromSerialization;
typedef int function(const NewtonCollision* treeCollision, const int* faceIndexArray) pfNewtonTreeCollisionGetFaceAtribute;
typedef void function(const NewtonCollision* treeCollision, const int* faceIndexArray, int attribute) pfNewtonTreeCollisionSetFaceAtribute;

pfNewtonCreateTreeCollision NewtonCreateTreeCollision;
pfNewtonTreeCollisionBeginBuild NewtonTreeCollisionBeginBuild;
pfNewtonTreeCollisionAddFace NewtonTreeCollisionAddFace;
pfNewtonTreeCollisionEndBuild NewtonTreeCollisionEndBuild;
pfNewtonTreeCollisionSerialize NewtonTreeCollisionSerialize;
pfNewtonCreateTreeCollisionFromSerialization NewtonCreateTreeCollisionFromSerialization;
pfNewtonTreeCollisionGetFaceAtribute NewtonTreeCollisionGetFaceAtribute;
pfNewtonTreeCollisionSetFaceAtribute NewtonTreeCollisionSetFaceAtribute;


// Collision Miscelaneos function
typedef void function(const NewtonWorld* newtonWorld, const NewtonCollision* collision) pfNewtonReleaseCollision;
typedef void function(const NewtonCollision* collision, const dFloat *matrix, dFloat* p0, dFloat* p1) pfNewtonCollisionCalculateAABB;
typedef dFloat function(const NewtonCollision* collision, const dFloat* p0, const dFloat* p1, dFloat* normals, int* attribute) pfNewtonCollisionRayCast;

pfNewtonReleaseCollision NewtonReleaseCollision;
pfNewtonCollisionCalculateAABB NewtonCollisionCalculateAABB;
pfNewtonCollisionRayCast NewtonCollisionRayCast;


// Transforms utility functions
typedef void function(const dFloat* matrix, dFloat* eulersAngles) pfNewtonGetEulerAngle;
typedef void function(const dFloat* eulersAngles, dFloat* matrix) pfNewtonSetEulerAngle;

pfNewtonGetEulerAngle NewtonGetEulerAngle;
pfNewtonSetEulerAngle NewtonSetEulerAngle;


// Body manipulation functions
typedef NewtonBody* function(const NewtonWorld* newtonWorld, const NewtonCollision* collision) pfNewtonCreateBody;
typedef void  function(const NewtonWorld* newtonWorld, const NewtonBody* body_) pfNewtonDestroyBody;
typedef void  function(const NewtonBody* body_, const dFloat* force) pfNewtonBodyAddForce;
typedef void  function(const NewtonBody* body_, const dFloat* torque) pfNewtonBodyAddTorque;
typedef void  function(const NewtonBody* body_, const dFloat* matrix) pfNewtonBodySetMatrix;
typedef void  function(const NewtonBody* body_, const dFloat* matrix) pfNewtonBodySetMatrixRecursive;
typedef void  function(const NewtonBody* body_, dFloat mass, dFloat Ixx, dFloat Iyy, dFloat Izz) pfNewtonBodySetMassMatrix;
typedef void  function(const NewtonBody* body_, int id) pfNewtonBodySetMaterialGroupID;
typedef void  function(const NewtonBody* body_, uint state) pfNewtonBodySetContinuousCollisionMode;
typedef void  function(const NewtonBody* body_, uint state) pfNewtonBodySetJointRecursiveCollision;
typedef void  function(const NewtonBody* body_, const dFloat* omega) pfNewtonBodySetOmega;
typedef void  function(const NewtonBody* body_, const dFloat* velocity) pfNewtonBodySetVelocity;
typedef void  function(const NewtonBody* body_, const dFloat* force) pfNewtonBodySetForce;
typedef void  function(const NewtonBody* body_, const dFloat* torque) pfNewtonBodySetTorque;
typedef void  function(const NewtonBody* body_, dFloat linearDamp) pfNewtonBodySetLinearDamping;
typedef void  function(const NewtonBody* body_, const dFloat* angularDamp) pfNewtonBodySetAngularDamping;
typedef void  function(const NewtonBody* body_, void* userData) pfNewtonBodySetUserData;
typedef void  function(const NewtonBody* body_, int mode) pfNewtonBodyCoriolisForcesMode;
typedef void  function(const NewtonBody* body_, const NewtonCollision* collision) pfNewtonBodySetCollision;
typedef void  function(const NewtonBody* body_, int state) pfNewtonBodySetAutoFreeze;
typedef void  function(const NewtonBody* body_, dFloat freezeSpeed2, dFloat freezeOmega2, int framesCount) pfNewtonBodySetFreezeTreshold;
typedef void  function(const NewtonBody* body_, NewtonSetTransform callback) pfNewtonBodySetTransformCallback;
typedef void  function(const NewtonBody* body_, NewtonBodyDestructor callback) pfNewtonBodySetDestructorCallback;
typedef void  function(const NewtonBody* body_, NewtonBodyActivationState callback) pfNewtonBodySetAutoactiveCallback;
typedef void  function(const NewtonBody* body_, NewtonApplyForceAndTorque callback) pfNewtonBodySetForceAndTorqueCallback;
typedef NewtonWorld* function(const NewtonBody* body_) pfNewtonBodyGetWorld;
typedef void* function(const NewtonBody* body_) pfNewtonBodyGetUserData;
typedef NewtonCollision* function(const NewtonBody* body_) pfNewtonBodyGetCollision;
typedef int   function(const NewtonBody* body_) pfNewtonBodyGetMaterialGroupID;
typedef int   function(const NewtonBody* body_) pfNewtonBodyGetContinuousCollisionMode;
typedef int   function(const NewtonBody* body_) pfNewtonBodyGetJointRecursiveCollision;
typedef void  function(const NewtonBody* body_, dFloat* matrix) pfNewtonBodyGetMatrix;
typedef void  function(const NewtonBody* body_, dFloat* mass, dFloat* Ixx, dFloat* Iyy, dFloat* Izz) pfNewtonBodyGetMassMatrix;
typedef void  function(const NewtonBody* body_, dFloat* invMass, dFloat* invIxx, dFloat* invIyy, dFloat* invIzz) pfNewtonBodyGetInvMass;
typedef void  function(const NewtonBody* body_, dFloat* vector) pfNewtonBodyGetOmega;
typedef void  function(const NewtonBody* body_, dFloat* vector) pfNewtonBodyGetVelocity;
typedef void  function(const NewtonBody* body_, dFloat* vector) pfNewtonBodyGetForce;
typedef void  function(const NewtonBody* body_, dFloat* vector) pfNewtonBodyGetTorque;
typedef int   function(const NewtonBody* body_) pfNewtonBodyGetSleepingState;
typedef int   function(const NewtonBody* body_) pfNewtonBodyGetAutoFreeze;
typedef dFloat function(const NewtonBody* body_) pfNewtonBodyGetLinearDamping;
typedef void  function(const NewtonBody* body_, dFloat* vector) pfNewtonBodyGetAngularDamping;
typedef void  function(const NewtonBody* body_, dFloat* p0, dFloat* p1) pfNewtonBodyGetAABB;
typedef void  function(const NewtonBody* body_, dFloat* freezeSpeed2, dFloat* freezeOmega2) pfNewtonBodyGetFreezeTreshold;
typedef dFloat function(const NewtonBody* body_) pfNewtonBodyGetTotalVolume;
typedef void  function(const NewtonBody* body_, dFloat fluidDensity, dFloat fluidLinearViscosity, dFloat fluidAngularViscosity, const dFloat* gravityVector, NewtonGetBuoyancyPlane buoyancyPlane, void *context) pfNewtonBodyAddBuoyancyForce;
typedef void function(const NewtonBody* body_, NewtonCollisionIterator callback) pfNewtonBodyForEachPolygonDo;
typedef void function(const NewtonBody* body_, const dFloat* pointDeltaVeloc, const dFloat* pointPosit) pfNewtonAddBodyImpulse;

pfNewtonCreateBody NewtonCreateBody;
pfNewtonDestroyBody NewtonDestroyBody;
pfNewtonBodyAddForce NewtonBodyAddForce;
pfNewtonBodyAddTorque NewtonBodyAddTorque;
pfNewtonBodySetMatrix NewtonBodySetMatrix;
pfNewtonBodySetMatrixRecursive NewtonBodySetMatrixRecursive;
pfNewtonBodySetMassMatrix NewtonBodySetMassMatrix;
pfNewtonBodySetMaterialGroupID NewtonBodySetMaterialGroupID;
pfNewtonBodySetContinuousCollisionMode NewtonBodySetContinuousCollisionMode;
pfNewtonBodySetJointRecursiveCollision NewtonBodySetJointRecursiveCollision;
pfNewtonBodySetOmega NewtonBodySetOmega;
pfNewtonBodySetVelocity NewtonBodySetVelocity;
pfNewtonBodySetForce NewtonBodySetForce;
pfNewtonBodySetTorque NewtonBodySetTorque;
pfNewtonBodySetLinearDamping NewtonBodySetLinearDamping;
pfNewtonBodySetAngularDamping NewtonBodySetAngularDamping;
pfNewtonBodySetUserData NewtonBodySetUserData;
pfNewtonBodyCoriolisForcesMode NewtonBodyCoriolisForcesMode;
pfNewtonBodySetCollision NewtonBodySetCollision;
pfNewtonBodySetAutoFreeze NewtonBodySetAutoFreeze;
pfNewtonBodySetFreezeTreshold NewtonBodySetFreezeTreshold;
pfNewtonBodySetTransformCallback NewtonBodySetTransformCallback;
pfNewtonBodySetDestructorCallback NewtonBodySetDestructorCallback;
pfNewtonBodySetAutoactiveCallback NewtonBodySetAutoactiveCallback;
pfNewtonBodySetForceAndTorqueCallback NewtonBodySetForceAndTorqueCallback;
pfNewtonBodyGetWorld NewtonBodyGetWorld;
pfNewtonBodyGetUserData NewtonBodyGetUserData;
pfNewtonBodyGetCollision NewtonBodyGetCollision;
pfNewtonBodyGetMaterialGroupID NewtonBodyGetMaterialGroupID;
pfNewtonBodyGetContinuousCollisionMode NewtonBodyGetContinuousCollisionMode;
pfNewtonBodyGetJointRecursiveCollision NewtonBodyGetJointRecursiveCollision;
pfNewtonBodyGetMatrix NewtonBodyGetMatrix;
pfNewtonBodyGetMassMatrix NewtonBodyGetMassMatrix;
pfNewtonBodyGetInvMass NewtonBodyGetInvMass;
pfNewtonBodyGetOmega NewtonBodyGetOmega;
pfNewtonBodyGetVelocity NewtonBodyGetVelocity;
pfNewtonBodyGetForce NewtonBodyGetForce;
pfNewtonBodyGetTorque NewtonBodyGetTorque;
pfNewtonBodyGetSleepingState NewtonBodyGetSleepingState;
pfNewtonBodyGetAutoFreeze NewtonBodyGetAutoFreeze;
pfNewtonBodyGetLinearDamping NewtonBodyGetLinearDamping;
pfNewtonBodyGetAngularDamping NewtonBodyGetAngularDamping;
pfNewtonBodyGetAABB NewtonBodyGetAABB;
pfNewtonBodyGetFreezeTreshold NewtonBodyGetFreezeTreshold;
pfNewtonBodyGetTotalVolume NewtonBodyGetTotalVolume;
pfNewtonBodyAddBuoyancyForce NewtonBodyAddBuoyancyForce;
pfNewtonBodyForEachPolygonDo NewtonBodyForEachPolygonDo;
pfNewtonAddBodyImpulse NewtonAddBodyImpulse;


// Common joint funtions
typedef void* function(const NewtonJoint* joint) pfNewtonJointGetUserData;
typedef void function(const NewtonJoint* joint, void* userData) pfNewtonJointSetUserData;
typedef int function(const NewtonJoint* joint) pfNewtonJointGetCollisionState;
typedef void function(const NewtonJoint* joint, int state) pfNewtonJointSetCollisionState;
typedef dFloat function(const NewtonJoint* joint) pfNewtonJointGetStiffness;
typedef void function(const NewtonJoint* joint, dFloat state) pfNewtonJointSetStiffness;
typedef void function(const NewtonWorld* newtonWorld, const NewtonJoint* joint) pfNewtonDestroyJoint;
typedef void function(const NewtonJoint* joint, NewtonConstraintDestructor destructor) pfNewtonJointSetDestructor;

pfNewtonJointGetUserData NewtonJointGetUserData;
pfNewtonJointSetUserData NewtonJointSetUserData;
pfNewtonJointGetCollisionState NewtonJointGetCollisionState;
pfNewtonJointSetCollisionState NewtonJointSetCollisionState;
pfNewtonJointGetStiffness NewtonJointGetStiffness;
pfNewtonJointSetStiffness NewtonJointSetStiffness;
pfNewtonDestroyJoint NewtonDestroyJoint;
pfNewtonJointSetDestructor NewtonJointSetDestructor;


// Ball and Socket joint functions
typedef NewtonJoint* function(const NewtonWorld* newtonWorld, const dFloat* pivotPoint, const NewtonBody* childBody, const NewtonBody* parentBody) pfNewtonConstraintCreateBall;
typedef void function(const NewtonJoint* ball, NewtonBallCallBack callback) pfNewtonBallSetUserCallback;
typedef void function(const NewtonJoint* ball, dFloat* angle) pfNewtonBallGetJointAngle;
typedef void function(const NewtonJoint* ball, dFloat* omega) pfNewtonBallGetJointOmega;
typedef void function(const NewtonJoint* ball, dFloat* force) pfNewtonBallGetJointForce;
typedef void function(const NewtonJoint* ball, const dFloat* pin, dFloat maxConeAngle, dFloat maxTwistAngle) pfNewtonBallSetConeLimits;

pfNewtonConstraintCreateBall NewtonConstraintCreateBall;
pfNewtonBallSetUserCallback NewtonBallSetUserCallback;
pfNewtonBallGetJointAngle NewtonBallGetJointAngle;
pfNewtonBallGetJointOmega NewtonBallGetJointOmega;
pfNewtonBallGetJointForce NewtonBallGetJointForce;
pfNewtonBallSetConeLimits NewtonBallSetConeLimits;


// Hinge joint functions
typedef NewtonJoint* function(const NewtonWorld* newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir, const NewtonBody* childBody, const NewtonBody* parentBody) pfNewtonConstraintCreateHinge;
typedef void function(const NewtonJoint* hinge, NewtonHingeCallBack callback) pfNewtonHingeSetUserCallback;
typedef dFloat function(const NewtonJoint* hinge) pfNewtonHingeGetJointAngle;
typedef dFloat function(const NewtonJoint* hinge) pfNewtonHingeGetJointOmega;
typedef void function(const NewtonJoint* hinge, dFloat* force) pfNewtonHingeGetJointForce;
typedef dFloat function(const NewtonJoint* hinge, const NewtonHingeSliderUpdateDesc* desc, dFloat angle) pfNewtonHingeCalculateStopAlpha;

pfNewtonConstraintCreateHinge NewtonConstraintCreateHinge;
pfNewtonHingeSetUserCallback NewtonHingeSetUserCallback;
pfNewtonHingeGetJointAngle NewtonHingeGetJointAngle;
pfNewtonHingeGetJointOmega NewtonHingeGetJointOmega;
pfNewtonHingeGetJointForce NewtonHingeGetJointForce;
pfNewtonHingeCalculateStopAlpha NewtonHingeCalculateStopAlpha;


// Slider joint functions
typedef NewtonJoint* function(const NewtonWorld* newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir, const NewtonBody* childBody, const NewtonBody* parentBody) pfNewtonConstraintCreateSlider;
typedef void function(const NewtonJoint* slider, NewtonSliderCallBack callback) pfNewtonSliderSetUserCallback;
typedef dFloat function(const NewtonJoint* slider) pfNewtonSliderGetJointPosit;
typedef dFloat function(const NewtonJoint* slider) pfNewtonSliderGetJointVeloc;
typedef void function(const NewtonJoint* slider, dFloat* force) pfNewtonSliderGetJointForce;
typedef dFloat function(const NewtonJoint* slider, const NewtonHingeSliderUpdateDesc* desc, dFloat position) pfNewtonSliderCalculateStopAccel;

pfNewtonConstraintCreateSlider NewtonConstraintCreateSlider;
pfNewtonSliderSetUserCallback NewtonSliderSetUserCallback;
pfNewtonSliderGetJointPosit NewtonSliderGetJointPosit;
pfNewtonSliderGetJointVeloc NewtonSliderGetJointVeloc;
pfNewtonSliderGetJointForce NewtonSliderGetJointForce;
pfNewtonSliderCalculateStopAccel NewtonSliderCalculateStopAccel;


// Corkscrew joint functions
typedef NewtonJoint* function(const NewtonWorld* newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir, const NewtonBody* childBody, const NewtonBody* parentBody) pfNewtonConstraintCreateCorkscrew;
typedef void function(const NewtonJoint* corkscrew, NewtonCorkscrewCallBack callback) pfNewtonCorkscrewSetUserCallback;
typedef dFloat function(const NewtonJoint* corkscrew) pfNewtonCorkscrewGetJointPosit;
typedef dFloat function(const NewtonJoint* corkscrew) pfNewtonCorkscrewGetJointAngle;
typedef dFloat function(const NewtonJoint* corkscrew) pfNewtonCorkscrewGetJointVeloc;
typedef dFloat function(const NewtonJoint* corkscrew) pfNewtonCorkscrewGetJointOmega;
typedef void function(const NewtonJoint* corkscrew, dFloat* force) pfNewtonCorkscrewGetJointForce;
typedef dFloat function(const NewtonJoint* corkscrew, const NewtonHingeSliderUpdateDesc* desc, dFloat angle) pfNewtonCorkscrewCalculateStopAlpha;
typedef dFloat function(const NewtonJoint* corkscrew, const NewtonHingeSliderUpdateDesc* desc, dFloat position) pfNewtonCorkscrewCalculateStopAccel;

pfNewtonConstraintCreateCorkscrew NewtonConstraintCreateCorkscrew;
pfNewtonCorkscrewSetUserCallback NewtonCorkscrewSetUserCallback;
pfNewtonCorkscrewGetJointPosit NewtonCorkscrewGetJointPosit;
pfNewtonCorkscrewGetJointAngle NewtonCorkscrewGetJointAngle;
pfNewtonCorkscrewGetJointVeloc NewtonCorkscrewGetJointVeloc;
pfNewtonCorkscrewGetJointOmega NewtonCorkscrewGetJointOmega;
pfNewtonCorkscrewGetJointForce NewtonCorkscrewGetJointForce;
pfNewtonCorkscrewCalculateStopAlpha NewtonCorkscrewCalculateStopAlpha;
pfNewtonCorkscrewCalculateStopAccel NewtonCorkscrewCalculateStopAccel;


// Universal joint functions
typedef NewtonJoint* function(const NewtonWorld* newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir0, const dFloat* pinDir1, const NewtonBody* childBody, const NewtonBody* parentBody) pfNewtonConstraintCreateUniversal;
typedef void function(const NewtonJoint* universal, NewtonUniversalCallBack callback) pfNewtonUniversalSetUserCallback;
typedef dFloat function(const NewtonJoint* universal) pfNewtonUniversalGetJointAngle0;
typedef dFloat function(const NewtonJoint* universal) pfNewtonUniversalGetJointAngle1;
typedef dFloat function(const NewtonJoint* universal) pfNewtonUniversalGetJointOmega0;
typedef dFloat function(const NewtonJoint* universal) pfNewtonUniversalGetJointOmega1;
typedef void function(const NewtonJoint* universal, dFloat* force) pfNewtonUniversalGetJointForce;
typedef dFloat function(const NewtonJoint* universal, const NewtonHingeSliderUpdateDesc* desc, dFloat angle) pfNewtonUniversalCalculateStopAlpha0;
typedef dFloat function(const NewtonJoint* universal, const NewtonHingeSliderUpdateDesc* desc, dFloat angle) pfNewtonUniversalCalculateStopAlpha1;

pfNewtonConstraintCreateUniversal NewtonConstraintCreateUniversal;
pfNewtonUniversalSetUserCallback NewtonUniversalSetUserCallback;
pfNewtonUniversalGetJointAngle0 NewtonUniversalGetJointAngle0;
pfNewtonUniversalGetJointAngle1 NewtonUniversalGetJointAngle1;
pfNewtonUniversalGetJointOmega0 NewtonUniversalGetJointOmega0;
pfNewtonUniversalGetJointOmega1 NewtonUniversalGetJointOmega1;
pfNewtonUniversalGetJointForce NewtonUniversalGetJointForce;
pfNewtonUniversalCalculateStopAlpha0 NewtonUniversalCalculateStopAlpha0;
pfNewtonUniversalCalculateStopAlpha1 NewtonUniversalCalculateStopAlpha1;


// Up vector joint functions
typedef NewtonJoint* function(const NewtonWorld* newtonWorld, const dFloat* pinDir, const NewtonBody* body_) pfNewtonConstraintCreateUpVector;
typedef void function(const NewtonJoint* upVector, dFloat *pin) pfNewtonUpVectorGetPin;
typedef void function(const NewtonJoint* upVector, const dFloat *pin) pfNewtonUpVectorSetPin;

pfNewtonConstraintCreateUpVector NewtonConstraintCreateUpVector;
pfNewtonUpVectorGetPin NewtonUpVectorGetPin;
pfNewtonUpVectorSetPin NewtonUpVectorSetPin;


// User defined bilateral Joint
typedef NewtonJoint* function(const NewtonWorld* newtonWorld, int maxDOF, NewtonUserBilateralCallBack callback, const NewtonBody* childBody, const NewtonBody* parentBody) pfNewtonConstraintCreateUserJoint;
typedef void function(const NewtonJoint* joint, const dFloat *pivot0, const dFloat *pivot1, const dFloat *dir) pfNewtonUserJointAddLinearRow;
typedef void function(const NewtonJoint* joint, dFloat relativeAngle, const dFloat *dir) pfNewtonUserJointAddAngularRow;
typedef void function(const NewtonJoint* joint, dFloat friction) pfNewtonUserJointSetRowMinimunFriction;
typedef void function(const NewtonJoint* joint, dFloat friction) pfNewtonUserJointSetRowMaximunFriction;
typedef void function(const NewtonJoint* joint, dFloat acceleration) pfNewtonUserJointSetRowAcceleration;
typedef void function(const NewtonJoint* joint, dFloat stiffness) pfNewtonUserJointSetRowStiffness;
typedef dFloat function(const NewtonJoint* joint, int row) pfNewtonUserJointGetRowForce;

pfNewtonConstraintCreateUserJoint NewtonConstraintCreateUserJoint;
pfNewtonUserJointAddLinearRow NewtonUserJointAddLinearRow;
pfNewtonUserJointAddAngularRow NewtonUserJointAddAngularRow;
pfNewtonUserJointSetRowMinimunFriction NewtonUserJointSetRowMinimunFriction;
pfNewtonUserJointSetRowMaximunFriction NewtonUserJointSetRowMaximunFriction;
pfNewtonUserJointSetRowAcceleration NewtonUserJointSetRowAcceleration;
pfNewtonUserJointSetRowStiffness NewtonUserJointSetRowStiffness;
pfNewtonUserJointGetRowForce NewtonUserJointGetRowForce;


// Ragdoll joint contatiner funtion
typedef NewtonRagDoll* function(const NewtonWorld* newtonWorld) pfNewtonCreateRagDoll;
typedef void function(const NewtonWorld* newtonWorld, const NewtonRagDoll* ragDoll) pfNewtonDestroyRagDoll;
typedef void function(const NewtonRagDoll* ragDoll) pfNewtonRagDollBegin;
typedef void function(const NewtonRagDoll* ragDoll) pfNewtonRagDollEnd;
typedef NewtonRagDollBone* function(const NewtonRagDoll* ragDoll, int id) pfNewtonRagDollFindBone;
// typedef NewtonRagDollBone* function(const NewtonRagDoll* ragDoll) pfNewtonRagDollGetRootBone;
typedef void function(const NewtonRagDoll* ragDoll, NewtonApplyForceAndTorque callback) pfNewtonRagDollSetForceAndTorqueCallback;
typedef void function(const NewtonRagDoll* ragDoll, NewtonSetRagDollTransform callback) pfNewtonRagDollSetTransformCallback;
typedef NewtonRagDollBone* function(const NewtonRagDoll* ragDoll, const NewtonRagDollBone* parent, void *userData, dFloat mass, const dFloat* matrix, const NewtonCollision* boneCollision, const dFloat* size) pfNewtonRagDollAddBone;
typedef void* function(const NewtonRagDollBone* bone) pfNewtonRagDollBoneGetUserData;
typedef NewtonBody* function(const NewtonRagDollBone* bone) pfNewtonRagDollBoneGetBody;
typedef void function(const NewtonRagDollBone* bone, int id) pfNewtonRagDollBoneSetID;
typedef void function(const NewtonRagDollBone* bone, const dFloat* coneDir, dFloat minConeAngle, dFloat maxConeAngle, dFloat maxTwistAngle, const dFloat* bilateralConeDir, dFloat negativeBilateralConeAngle, dFloat positiveBilateralConeAngle) pfNewtonRagDollBoneSetLimits;
typedef void function(const NewtonRagDollBone* bone, dFloat* matrix) pfNewtonRagDollBoneGetLocalMatrix;
typedef void function(const NewtonRagDollBone* bone, dFloat* matrix) pfNewtonRagDollBoneGetGlobalMatrix;

pfNewtonCreateRagDoll NewtonCreateRagDoll;
pfNewtonDestroyRagDoll NewtonDestroyRagDoll;
pfNewtonRagDollBegin NewtonRagDollBegin;
pfNewtonRagDollEnd NewtonRagDollEnd;
pfNewtonRagDollFindBone NewtonRagDollFindBone;
// pfNewtonRagDollGetRootBone NewtonRagDollGetRootBone;
pfNewtonRagDollSetForceAndTorqueCallback NewtonRagDollSetForceAndTorqueCallback;
pfNewtonRagDollSetTransformCallback NewtonRagDollSetTransformCallback;
pfNewtonRagDollAddBone NewtonRagDollAddBone;
pfNewtonRagDollBoneGetUserData NewtonRagDollBoneGetUserData;
pfNewtonRagDollBoneGetBody NewtonRagDollBoneGetBody;
pfNewtonRagDollBoneSetID NewtonRagDollBoneSetID;
pfNewtonRagDollBoneSetLimits NewtonRagDollBoneSetLimits;
pfNewtonRagDollBoneGetLocalMatrix NewtonRagDollBoneGetLocalMatrix;
pfNewtonRagDollBoneGetGlobalMatrix NewtonRagDollBoneGetGlobalMatrix;


// Vehicle
typedef NewtonJoint* function(const NewtonWorld* newtonWorld, const dFloat* upDir, const NewtonBody* body_) pfNewtonConstraintCreateVehicle;
typedef void function(const NewtonJoint* vehicle) pfNewtonVehicleReset;
typedef void function(const NewtonJoint* vehicle, NewtonVehicleTireUpdate update) pfNewtonVehicleSetTireCallback;
typedef int function(const NewtonJoint* vehicle, const dFloat* localMatrix, const dFloat* pin, dFloat mass, dFloat width, dFloat radius, dFloat suspesionShock, dFloat suspesionSpring, dFloat suspesionLength, void* userData, int collisionID) pfNewtonVehicleAddTire;
typedef void function(const NewtonJoint* vehicle, int tireIndex) pfNewtonVehicleRemoveTire;
typedef void function(const NewtonJoint* vehicle, dFloat gravityMag) pfNewtonVehicleBalanceTires;
typedef int function(const NewtonJoint* vehicle) pfNewtonVehicleGetFirstTireID;
typedef int function(const NewtonJoint* vehicle, int tireId) pfNewtonVehicleGetNextTireID;
typedef int function(const NewtonJoint* vehicle, int tireId) pfNewtonVehicleTireIsAirBorne;
typedef int function(const NewtonJoint* vehicle, int tireId) pfNewtonVehicleTireLostSideGrip;
typedef int function(const NewtonJoint* vehicle, int tireId) pfNewtonVehicleTireLostTraction;
typedef void* function(const NewtonJoint* vehicle, int tireId) pfNewtonVehicleGetTireUserData;
typedef dFloat function(const NewtonJoint* vehicle, int tireId) pfNewtonVehicleGetTireOmega;
typedef dFloat function(const NewtonJoint* vehicle, int tireId) pfNewtonVehicleGetTireNormalLoad;
typedef dFloat function(const NewtonJoint* vehicle, int tireId) pfNewtonVehicleGetTireSteerAngle;
typedef dFloat function(const NewtonJoint* vehicle, int tireId) pfNewtonVehicleGetTireLateralSpeed;
typedef dFloat function(const NewtonJoint* vehicle, int tireId) pfNewtonVehicleGetTireLongitudinalSpeed;
typedef void function(const NewtonJoint* vehicle, int tireId, dFloat* matrix) pfNewtonVehicleGetTireMatrix;
typedef void function(const NewtonJoint* vehicle, int tireId, dFloat torque) pfNewtonVehicleSetTireTorque;
typedef void function(const NewtonJoint* vehicle, int tireId, dFloat angle) pfNewtonVehicleSetTireSteerAngle;
typedef void function(const NewtonJoint* vehicle, int tireId, dFloat speed) pfNewtonVehicleSetTireMaxSideSleepSpeed;
typedef void function(const NewtonJoint* vehicle, int tireId, dFloat coeficient) pfNewtonVehicleSetTireSideSleepCoeficient;
typedef void function(const NewtonJoint* vehicle, int tireId, dFloat speed) pfNewtonVehicleSetTireMaxLongitudinalSlideSpeed;
typedef void function(const NewtonJoint* vehicle, int tireId, dFloat coeficient) pfNewtonVehicleSetTireLongitudinalSlideCoeficient;
typedef dFloat function(const NewtonJoint* vehicle, int tireId) pfNewtonVehicleTireCalculateMaxBrakeAcceleration;
typedef void function(const NewtonJoint* vehicle, int tireId, dFloat accelaration, dFloat torqueLimit) pfNewtonVehicleTireSetBrakeAcceleration;

pfNewtonConstraintCreateVehicle NewtonConstraintCreateVehicle;
pfNewtonVehicleReset NewtonVehicleReset;
pfNewtonVehicleSetTireCallback NewtonVehicleSetTireCallback;
pfNewtonVehicleAddTire NewtonVehicleAddTire;
pfNewtonVehicleRemoveTire NewtonVehicleRemoveTire;
pfNewtonVehicleBalanceTires NewtonVehicleBalanceTires;
pfNewtonVehicleGetFirstTireID NewtonVehicleGetFirstTireID;
pfNewtonVehicleGetNextTireID NewtonVehicleGetNextTireID;
pfNewtonVehicleTireIsAirBorne NewtonVehicleTireIsAirBorne;
pfNewtonVehicleTireLostSideGrip NewtonVehicleTireLostSideGrip;
pfNewtonVehicleTireLostTraction NewtonVehicleTireLostTraction;
pfNewtonVehicleGetTireUserData NewtonVehicleGetTireUserData;
pfNewtonVehicleGetTireOmega NewtonVehicleGetTireOmega;
pfNewtonVehicleGetTireNormalLoad NewtonVehicleGetTireNormalLoad;
pfNewtonVehicleGetTireSteerAngle NewtonVehicleGetTireSteerAngle;
pfNewtonVehicleGetTireLateralSpeed NewtonVehicleGetTireLateralSpeed;
pfNewtonVehicleGetTireLongitudinalSpeed NewtonVehicleGetTireLongitudinalSpeed;
pfNewtonVehicleGetTireMatrix NewtonVehicleGetTireMatrix;
pfNewtonVehicleSetTireTorque NewtonVehicleSetTireTorque;
pfNewtonVehicleSetTireSteerAngle NewtonVehicleSetTireSteerAngle;
pfNewtonVehicleSetTireMaxSideSleepSpeed NewtonVehicleSetTireMaxSideSleepSpeed;
pfNewtonVehicleSetTireSideSleepCoeficient NewtonVehicleSetTireSideSleepCoeficient;
pfNewtonVehicleSetTireMaxLongitudinalSlideSpeed NewtonVehicleSetTireMaxLongitudinalSlideSpeed;
pfNewtonVehicleSetTireLongitudinalSlideCoeficient NewtonVehicleSetTireLongitudinalSlideCoeficient;
pfNewtonVehicleTireCalculateMaxBrakeAcceleration NewtonVehicleTireCalculateMaxBrakeAcceleration;
pfNewtonVehicleTireSetBrakeAcceleration NewtonVehicleTireSetBrakeAcceleration;
